//
//  WBEmotionButton.m
//  新浪微博项目
//
//  Created by neng on 15/12/23.
//  Copyright (c) 2015年 neng. All rights reserved.
//

#import "WBEmotionButton.h"
#import "WBEmotion.h"
#import "NSString+Emoji.h"

@implementation WBEmotionButton

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self setUp];
    }
    return self;
}

//从xib或者storyboard创建时调用
- (id)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super initWithCoder:aDecoder]) {
        [self setUp];
    }
    return self;
}

//初始化方法
- (void)setUp
{
    self.titleLabel.font = [UIFont systemFontOfSize:32];
    //取消高亮效果
    self.adjustsImageWhenHighlighted = NO;
}

- (void)setEmotion:(WBEmotion *)emotion
{
    _emotion = emotion;
    
    if (emotion.png) {
        
        [self setImage:[UIImage imageNamed:emotion.png] forState:UIControlStateNormal];
    }else { //emoji字符表情
        
        [self setTitle:emotion.code.emoji forState:UIControlStateNormal];
        
    }
}

@end
